package com.example.memohehang.controller;

import com.example.memohehang.common.R;
import com.example.memohehang.domain.User;
import com.example.memohehang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    private UserService userService;

    // 登录功能
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public R login(@RequestBody User user)
    {
        return userService.login(user);

    }

    // 注册功能
    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public R register(@RequestBody User user)
    {
        return userService.register(user);
    }

    // 根据用户id查询
    @RequestMapping ("/selectUserById/{userid}")
    @ResponseBody
    public R selectUserById(@PathVariable("userid") Integer userid)
    {
        return userService.selectUserById(userid);
    }

}



